#include <iostream>
#include <set>

using namespace std;
typedef unsigned long NUM;

int main()
{
	multiset<NUM> numbers;

	for(NUM a = 1; a <= 100000000; a++)
	{
		NUM b, i;
		multiset<NUM> a_digits, x_digits;

		for (i = a; i; i /= 10)
			a_digits.insert(i % 10);

		for(b = 2; b <= 6; b++)
		{
			for (i = a*b; i; i /= 10)
				x_digits.insert(i % 10);

			if (a_digits.size() != x_digits.size())
				break;

			for (i = 0; i < 10 && a_digits.count(i) == x_digits.count(i); i++);
			if (i < 10)
				break;

			x_digits.clear();
		}

		if (b > 6)
		{
			cout << a << endl;
			break;
		}

	}
	return 0;
}


/*
Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x, and 6x, contain the same digits.
*/
